<?php
namespace app\adminjcb\controller;

use app\adminjcb\model\Ad as ArticleModel;
use app\common\controller\AdminBaseController;

/**
 * 订单
 */
class PorderController extends AdminBaseController {
    protected $article_model;

    protected function _initialize() {
        parent::_initialize();
        $this->article_model  = new ArticleModel();
    }

    /**
     * 订单
     * @param int    $cid 分类ID
     * @param string $keyword 关键词
     * @param int    $page
     * @return mixed
     */
    public function index() {
    	$status=1;
		if(input("status")){
			$status=input("status");
		}
		$this->assign('status',$status);
        $article_list  = db('porder')->where("status",$status)->select();
        return $this->fetch('index', ['article_list' => $article_list]);
    }

    /**
     * 保存
     */
    public function confirm() {
        $res=db("porder")->where("id",input("id"))->update(["status"=>2]);
		if($res){
			return json(['code'=>200,'msg'=>'操作成功']);
		}else{
			return json(['code'=>200,'msg'=>'操作失败']);
		}
    }

   

    /**
     * 删除
     * @param int   $id
     * @param array $ids
     */
    public function delete($id = 0) {
        $res=db('product')->where("id",$id)->update(['status'=>2]);
        if ($res) {
            $this->success('操作成功',url('product/index'));
        } else {
            $this->error('删除失败');
        }
    }

}
